<?php
global $Config;
require_once($Config->WebCMSRoot.'Base/View.php');

Class SlideshowView extends BaseView
{
	function SlideshowView()
	{
		parent::BaseView();
	}
	
	function ShowSlideshow($slideshow)
	{
//print('<pre>' . var_export($slideshow->Collection, true) . '</pre>');exit;
		$this->output  = '';
		if (count($slideshow))
		{
			if (count($slideshow->Collection))
			{
				if (count($slideshow->Collection[0]->Images))
				{
					$this->output .= '<a href="#" class="prev">&lt;&lt;</a>';
					$this->output .= '<div class="slideshow">';
					$this->output .= '<ul>';

$test = '';					
					foreach ($slideshow->Collection[0]->Images as $key=>$image)
					{
//print('<pre>' . var_export($image, true) . '</pre>');exit;
$test .= $image->Thumbnail.'<br />';
//print($image->Thumbnail.'<br />');
						$this->output .= '<li><img src="' . $image->Thumbnail . '" alt="" /></li>';
					}
print($test);
					$this->output .= '</ul>';
					$this->output .= '</div>';
					$this->output .= '<a href="#" class="next">&gt;&gt;</a>';

					//$this->output .= '<img id="foto" src="' . $slideshow->Collection[0]->Images[0]->File . '" alt="" />';
				}
			}
		}
//print("Slideshow");
//print('<pre>' . var_export($slideshow, true) . '</pre>');//exit;
	}
	
	/*function ShowOverview($slideshow, $page, $count)
	{
		$this->output  = '<h2>Referenties</h2>';
		if (count($slideshow) > 0)
		{
			$this->output .= '<div class="pageBrowser">Blader: ';
			for ($i=0; $i*$count < count($slideshow); $i++)
			{
				if ($i != $page)
				{
					$this->output .= '<a class="pageLink" href="/referenties/overview/' . ($i+1) . '">' . ($i+1) . '</a>';
				}
				else
				{
					$this->output .= '<span class="pageLink">' . ($i+1) . '</span>';
				}
			}
			$this->output .= '</div>';
			for ($i=($page * $count); $i < (($page * $count) + $count) && $i < count($slideshow); $i++)
			{
				$this->output .= '<div class="overviewItem">';
				$this->output .= '<h3><a href="/referenties/' . $slideshow[$i]->Key . '">'.$slideshow[$i]->Title.'</a></h3>';
				$this->output .= '<p>' . nl2br($slideshow[$i]->Summary) . '</p>';
				$this->output .= '<div class="overviewThumbs" id="overview_'.$slideshow[$i]->ID.'">';
				if (count($slideshow[$i]->Images) > 0)
				{
					for ($j=0; $j < count($slideshow[$i]->Images) && $j < 3; $j++)
					{
						$this->output .= '<img id="thumb'.$slideshow[$i]->Images[$j]->ID.'" src="'.$slideshow[$i]->Images[$j]->Thumbnail.'" class="thumb" alt="'.$slideshow[$i]->Title.'" />';
					}
				}
				$this->output .= '</div>';
				$this->output .= '<a href="/referenties/' . $slideshow[$i]->Key . '" class="details">Details</a>';
				$this->output .= '</div>';
			}
		}
		else
		{
			$this->output .= '<span style="font-style:italic;">Momenteel zijn er geen referenties</span>';
		}
	}*/
	
	/*function ShowReferentie($slideshow)
	{
		$this->output .= '<h2>'.$slideshow->Title.'</h2>';
		$this->ShowJQueryCycleSlideShow($slideshow);
		$this->output .= '<p class="summary">' . nl2br($slideshow->Summary) . '</p>';
		$this->output .= '<p>'.nl2br($slideshow->Description).'</p>';
		$this->output .= '<a class="details" href="/referenties/overview">Meer Referenties</a>';
	}*/
	
	function ShowJQueryCycleSlideShow($slideshow)
	{
		if (count($slideshow->Images))
		{
			$this->output .= '<div id="referentieThumbs">';
			$this->output .= '<div class="footnote">(klik om te vergroten)</div>';
			$this->output .= '<div class="thumbs">';
			
			foreach ($slideshow->Images as $key=>$image)
			{
				$this->output .= '<a href="'.$image->File.'" target="_blank"><img id="thumb'.$image->ID.'" src="'.$image->Thumbnail.'" class="thumb" alt="'.$slideshow->Title.'" /></a>';
			}
	        $this->output .= '</div>';
	        $this->output .= '</div>';
			$this->output .= '<script type="text/javascript">';
			$this->output .= '  $(function() {';
			$this->output .= '    $(\'#referentieThumbs .thumbs\').before(\'<div id="referentieNav">\').cycle({ ';
			$this->output .= '      fx:    \'fade\',';
			$this->output .= '      pause: 3000,';
			$this->output .= '      pager: \'#referentieNav\'';
			$this->output .= '    });';
			$this->output .= '  });';
			$this->output .= '</script>';
		}
	}
	
	function ClientSideTemplates()
	{
		$templates = array(
			'referenties' => array(
				'overview' => '<div class="overview_item" id="Slideshow_[$ID$]">'.
							  '<div class="overviewKey">[$Key$]</div>'.
							  '<div class="overviewPage">[$PageID$]<br />'.
							  '<div class="overviewDescription">[$Description$]<br />'.
				              '<div class="overview_actions">'.
							  '<a href="#" onClick="Slideshow_Edit_Item([$ID$])">Bewerken</a>'.
							  '<a href="#" onClick="confirm(\'Bent u zeker dat u \\\'[$JSSafeTitle$]\\\' wilt verwijderen?\', function() { Slideshow_Delete_Item([$ID$]); } )">Verwijderen</a>'.
							  '<a href="#" onClick="Slideshow_Photos_Item([$ID$])">Foto\'s</a> '.
							  '</div>'.
							  '</div>'.
							  '</div>',
				/*'sortButton' => '<div class="overview_actions">'.
								'<span style="font-style: italic;text-decoration: line-through;">(Sleep de items om de volgorde te bepalen)</span>'.
								'<span style="font-style: italic;"> Tijdelijk niet mogelijk </span>'.
								'<a href="#" onClick="Referenties_SaveOrder()">Bewaar Volgorde</a>'.
								'</div>',
				'edit' => '<div class="edit_item form">'.
						  '<div class="formFieldLabel"><label for="referentieTitle">Naam:</label></div>'.
						  '<div class="formFieldEntry"><input type="text" value="[$Title$]" id="referentieTitle" name="referentieTitle" maxlength="100" size="50" /></div>'.
						  '<div class="formFieldLabel"><label for="referentieSummary">Intro Tekst:</label></div>'.
						  '<div class="formFieldEntry"><textarea id="referentieSummary" name="referentieSummary" cols="50" rows="2">[$Summary$]</textarea></div>'.
						  '<div class="formFieldLabel"><label for="referentieDescription">Omschrijving:</label></div>'.
						  '<div class="formFieldEntry"><textarea id="referentieDescription" name="referentieDescription" cols="50" rows="5">[$Description$]</textarea></div>'.
						  '<div class="formFieldLabel"><label for="referentieDateAdded">Datum Toegevoegd:</label></div>'.
						  '<div class="formFieldEntry"><input type="text" value="[$DateAdded$]" id="referentieDateAdded" name="referentieDateAdded" disabled="disabled" size="20" /></div>'.
						  '<div class="formFieldLabel"><label for="linkedTo">Gekoppeld Aan:</label></div>'.
						  '<div class="formFieldEntry"><div style="font-style:italic; clear: none; float: right;width: 180px;">Selecteer meerdere met [Shift] en [Ctrl] toetsen</div><select id="linkedTo" multiple="multiple" size="5" style="width:425px"></select></div>'.
						  '<div class="formFieldLabel">Foto\'s:</div>'.
						  '<div class="formFieldEntry">{#template_referenties_images#}</div>'.
				          '<div class="overview_actions">'.
						  '<a href="#" onClick="Referenties_Overview()">Annuleren</a> '.
						  '<a href="#" onClick="Referenties_Save([$ID$])">Opslaan</a> '.
						  '<a href="#" onClick="confirm(\'Bent u zeker dat u \\\'[$JSSafeTitle$]\\\' \\n\\nwilt verwijderen?\', function() { Referenties_Delete_Item([$ID$]); } )" id="btnReferenties_Edit_Delete">Verwijderen</a> '.
						  '<a href="#" onClick="Referenties_Photos_Item([$ID$])">Foto\'s</a> '.
						  '</div>'.
						  '</div>',
				'photos' => '<div class="edit_item form">'.
						    '<h2>[$Title$]</h2>'.
						    '[$Summary$]<br /><br />'.
						    '<div>{#template_referenties_images#}</div>'.
				            '<div class="overview_actions">'.
						    '<a href="#" onClick="Referenties_Overview()">Annuleren</a> '.
						    '<a href="#" onClick="Referenties_Photo_Add([$ID$], adminRoot + \'referenties/imageUpload/[$ID$]\')">Toevoegen</a> '.
						    '</div>'.
						    '</div>',
				'thumbnail' => '<div class="edit_thumbnail">'.
						  '<img src="[$Thumbnail$]" alt="[$File$]" /><br />'.
						  '[$File$]'.
						  '</div>',
				'managephotos' => '<div class="edit_thumbnail">'.
						  '<img src="[$Thumbnail$]" alt="[$File$]" /><br />'.
						  '[$File$]<br />'.
						  '<a href="#" class="button" onClick="confirm(\'Bent u zeker dat u deze foto wilt verwijderen?\', function() { Referenties_Photos_Delete([$ID$], [$_parentID$]); } )">Verwijder</a>'.
						  '</div>'*/
			)
		);
		$this->JsonOutput($templates);
	}
	
	/*function ShowMenuList(&$slideshow)
	{
		$this->output  = '<div class="nav1">';
		if (count($slideshow) > 0)
		{
			$this->output .= '<ul>';
			foreach($slideshow as $key=>$slideshow)
			{
				$this->output .= '<li><a href="/referenties/' . $slideshow->Key . '">' . $slideshow->Title . '</a></li>';
			}
			$this->output .= '</ul>';
		}
		else
		{
			$this->output .= '<span style="font-style:italic;font-weight:normal;font-size:80%">Momenteel geen referenties</span>';
		}
		$this->output .= '</div>';
	}*/
}
?>